package Figures;

import java.awt.*;
import java.io.Serializable;

/**
 * 类功能描述：
 *直角三角形类
 * <br>重写了setEend方法来设置直角三角形的三个点
 * @author lix
 * @date 2024/01/02
 */

public class RightAngledTriangle extends Triangle implements Serializable {
    public RightAngledTriangle(Point start, Point end, int size, Color color) {
        super(start, end, size, color);
    }

    @Override
    public void setEnd(Point end) {
        super.setEnd(end);
        calcPoint_left_top();
        calcPoint_right_bottom();
        calcWidthAndHeight();
        triangle_x = new int[]{start.x,start.x,end.x};
        triangle_y = new int[]{start.y,end.y,end.y};
        triangle = new Polygon(triangle_x,triangle_y,3);
        point_center = new Point(((point_left_top.x+point_right_bottom.x)/2),(point_left_top.y+point_right_bottom.y)/2);
    }

    @Override
    public void Move(Point destination) {
        super.Move(destination);
        triangle_x = new int[]{start.x,start.x,end.x};
        triangle_y = new int[]{start.y,end.y,end.y};
        triangle = new Polygon(triangle_x,triangle_y,3);
    }
}
